home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-12-20 | 5.1 KB | 160 lines | [TEXT/CWIE] |
- ///////////////////////////////////////////////////////////////////////////////
- //
- // CPopupWindowControl.h
- //
- // The PopupWindow control is designed to bring up a window whenever the
- // mouse moves over the label designated as its source. Inside the window,
- // PopupWindow renders the contents of the specified URL
- //
- // In this demonstration version, a mouse click in the specified label is
- // required, pending implementatin of a mouseOver event.
- //
- // In this demonstration version, only pict files are rendered, pending
- // implementation of MSHTML to render the contents of URL's.
- //
- // In this demonstration version, the image is rendered in a rect within
- // the browser window rather than in a separate window.
- //
-
- #ifndef __CPOPUPWINDOWCONTROL__
- #define __CPOPUPWINDOWCONTROL__
-
- #include "BDInterfaces.h"
- #include "CBaseBindStatusCallback.h"
- #include "CErrorControl.h"
-
- ///////////////////////////////////////////////////////////////////////////////
- //
- // Constants
- //
-
- const short cNumConnections = 1; // This control only has one connection point
- const short cMaxNumSourceControls = 50; // an arbitrary limit. We could make this dynamic.
- const char cSourceObjectStr[] = "sourceobject"; // HTML parameter name
- const unsigned long cPictHeaderSize = 512; // Pict file header size
- const char cPopupControlName[] = "Popup"; // Default name for the control.
- const char cEmptyCString[] = "";
-
- ///////////////////////////////////////////////////////////////////////////////
- //
- // Data Structures
- //
-
- typedef struct
- {
- Rect PicRect;
- PicHandle Pic;
- }
- pictInfo;
-
- ///////////////////////////////////////////////////////////////////////////////
-
- class CBaseBindStatusCallback;
- class CPopupWindowError;
-
- ///////////////////////////////////////////////////////////////////////////////
- //
- // class declaration
- //
-
- class CPopupWindowControl :
- public CBaseControl,
- public CBaseBindStatusCallback,
- public IDoMenuEvents,
- public CErrorControl
- {
- public:
-
- // *** CPopupWindowControl methods ***
- CPopupWindowControl ();
- ~CPopupWindowControl ();
-
- // *** IUnknown methods ***
- STDMETHOD (QueryInterface) ( REFIID RefID, void** Obj );
- STDMETHOD_ (ULONG, AddRef) ( THIS ) { return (CBaseControl::AddRef ()); }
- STDMETHOD_ (ULONG, Release) ( THIS ) { return (CBaseControl::Release ()); }
-
- // *** IObjectWithSite methods ***
- STDMETHOD (SetSite) ( THIS_ IUnknown* inUnkSite );
-
- // *** IControl methods ***
- STDMETHOD (Draw) ( DrawContext* Context );
- STDMETHOD (DoIdle) ( THIS_ Uint32 IdleRefCon );
-
- // *** IPersistPropertyBag methods ***
- STDMETHOD (Load) ( IPropertyBag* PropBag, IErrorLog* ErrorLog );
-
- // *** CBaseBindStatusCallback methods ***
- STDMETHOD (OnStopBinding) ( ErrorCode Result, const Char8* Error );
- STDMETHOD (OnDataAvailable) ( Uint32 BSCF,
- Uint32 Size,
- FORMATETC* FormatEtc,
- STGMEDIUM* StgMedium );
-
- // **** IDoMenuEvents methods
- STDMETHOD (Popup) ( THIS_ IUnknown* Source, PlatformEvent* Event );
-
- // These are IDoMenuEvents methods which PopupWindow doesn't need.
- STDMETHOD (Clear) ( THIS_ IUnknown* /* Source */, PlatformEvent* /* Event */ )
- { return ResultFromScode ( E_NOTIMPL ); }
- STDMETHOD (RemoveItem) ( THIS_ IUnknown* /* Source */,
- PlatformEvent* /* Event */,
- const CMenuItem & /* Item */ )
- { return ResultFromScode ( E_NOTIMPL ); }
- STDMETHOD (AddItem) ( THIS_ IUnknown* /* Source */,
- PlatformEvent* /* Event */,
- const CMenuItem & /* Item */ )
- { return ResultFromScode ( E_NOTIMPL ); }
-
- friend CPopupWindowError;
-
- protected:
- Boolean SetName ( const char * theName );
- Boolean SetSourceName ( const char * theName );
- Boolean AddDesiredSourceName ( const char * theName );
- Boolean AddSource ( const char * sourceName, Boolean * alreadyFoundIt );
- Boolean IsSource ( IUnknown * unk );
- Boolean IsSource ( const char * sourceName );
- void DrawPict ( GrafPtr pGrafDraw,
- Rect* lprect,
- PicHandle Pic,
- Rect* PictRect );
- Boolean AllocatePictBuffer ( void );
- Boolean ReadPictHeader ( STGMEDIUM* StgMedium );
- Boolean ReadPictData ( STGMEDIUM* StgMedium );
-
- protected:
- char * mSourceName;
- char * mDesiredSourceNames[cMaxNumSourceControls];
- // the names of the specific controls that we want to get messages from
- char * mFoundSourceNames[cMaxNumSourceControls];
- // the names of the specific controls that we've connected to
- long mNumDesiredSources;
- long mNumFoundSources;
- Boolean mIsIdling; // True if we're getting idle messages
- #ifdef _DEBUG
- char mThisName[256];
- #endif
- Int32 mPictBytesRemaining;
- Int32 mPictBytesSoFar;
- GrafPtr mDrawPort;
- Uchar8 mDataURL[MAX_URL_STRING];
- LPBINDHOST mBindSiteP;
- pictInfo** mPict;
- Boolean mPictIsLoaded;
- Boolean mPendingDraw;
- unsigned long mPopupWidth;
- unsigned long mPopupHeight;
- Boolean mFatalError; // After failure, so I don't respond.
-
- private:
- DWORD mCookie;
- // NOTE: if we ever actually use this for something, we need a
- // list of them, since we allow connections to more than
- // one specific sources.
- Boolean mConnectingComplete;
- };
-
-
- #endif // __CPOPUPWINDOWCONTROL__
-